//
//  File.swift
//  Rx
//
//  Created by 齐凯 on 2018/11/12.
//  Copyright © 2018年 齐凯. All rights reserved.

import SnapKit     //swift 自动布局


let KscreenWidth = UIScreen.main.bounds.size.width
let KscreenHigth = UIScreen.main.bounds.size.height

//判断 iPhone 的屏幕尺寸
let kSCREEN_MAX_LENGTH = max(KscreenWidth, KscreenHigth)
let kSCREEN_MIN_LENGTH = min(KscreenWidth, KscreenHigth)
//机型判断
let kUI_IPHONE = (UIDevice.current.userInterfaceIdiom == .phone)
let kUI_IPHONE5 = (kUI_IPHONE && kSCREEN_MAX_LENGTH == 568.0)
let kUI_IPHONE6 = (kUI_IPHONE && kSCREEN_MAX_LENGTH == 667.0)
let kUI_IPHONEPLUS = (kUI_IPHONE && kSCREEN_MAX_LENGTH == 736.0)
let kUI_IPHONEX = (kUI_IPHONE && kSCREEN_MAX_LENGTH > 780.0)

//获取状态栏、标题栏、导航栏高度
let kUIStatusBarHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
let kUINavigationBarHeight: CGFloat =  kUI_IPHONEX ? 88 : 44
let KUITabBarHeight: CGFloat = kUI_IPHONEX ? 83 : 49

/// 当前app信息
let kGetAppInfo = Bundle.main.infoDictionary
/// 当前app版本号
let kGetAppCurrentVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")
/// 获取设备系统号
let kGetSystemVersion = UIDevice.current.systemVersion



// 注册通知
func kNOTIFY_ADD(observer: Any, selector: Selector, name: String) {
    return NotificationCenter.default.addObserver(observer, selector: selector, name: Notification.Name(rawValue: name), object: nil)
}
// 发送通知
func kNOTIFY_POST(name: String, object: Any) {
    return NotificationCenter.default.post(name: Notification.Name(rawValue: name), object: object)
}
// 移除通知
func kNOTIFY_REMOVE(observer: Any, name: String) {
    return NotificationCenter.default.removeObserver(observer, name: Notification.Name(rawValue: name), object: nil)
}


// UserDefaults 操作
let kUserDefaults = UserDefaults.standard
func kUserDefaultsRead(_ KeyStr: String) -> String {
    return kUserDefaults.string(forKey: KeyStr)!
}
func kUserDefaultsWrite(_ obj: Any, _ KeyStr: String) {
    kUserDefaults.set(obj, forKey: KeyStr)
    //kUserDefaults.synchronize() //立即写入
}
func kUserValue(_ A: String) -> Any? {
    return kUserDefaults.value(forKey: A)
}


//获取沙盒Document路径
let kDocumentPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first
//获取沙盒Cache路径
let kCachePath    = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first
//获取沙盒temp路径
let kTempPath = NSTemporaryDirectory()







